package com.music.factory;

import com.music.myenum.SmsType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 工厂: 发送验证码，邮箱
 */
@Component
public class SendFactory {

	@Autowired
	private PhoneSender phoneSender;

	@Autowired
	private QQEmailSender qqEmailSender;

	public Sender produce(SmsType type) {
		// 也可以
//		if(type == SmsType.PHONE) {}

		switch (type) {
			case PHONE:
				return phoneSender;
			case QQEMAIL:
				return qqEmailSender;
		}

//		if("QQEmail".equals(type)) return qqEmailSender;
//
//		if("phone".equals(type)) return phoneSender;

		System.out.println("发送消息类型出错！！！");
		return null;
	}

}
